package com.hnucm.c202001020214;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.util.Log;
import android.widget.Button;

import com.hnucm.c202001020214.object.Book;
import com.hnucm.c202001020214.object.Goods;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.List;

public class ShoppingCart extends AppCompatActivity {
Button buy;
    RecyclerView recyclerView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shopping_cart);

        EventBus.getDefault().register(this);  //注册eventbus,



    }
    @Subscribe(threadMode = ThreadMode.MAIN,sticky = true)//指定线程
    public void mesge(List<Book> q){
        recyclerView =findViewById(R.id.recyclerview01);
        LinearLayoutManager layoutManager = new LinearLayoutManager(ShoppingCart.this);
        recyclerView.setLayoutManager(layoutManager);

        BookAdapter bookAdapter = new BookAdapter(q);
        Log.i("qwe",q.toString());

        recyclerView.setAdapter(bookAdapter);

    }

}